package com.civil.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.civil.response.DataResponse;
import com.civil.service.CivilService;


@RestController()
@RequestMapping("/admin/Civil/")
public class CivilController {

	@Autowired
	CivilService officialInfoService;
	
	@PostMapping("insert")
	public DataResponse insert(@RequestBody Map<String, Object> params) {
		
		officialInfoService.insert(params);
		return DataResponse.isOk();
	}
	
	@PostMapping("findList")
	public DataResponse findList(@RequestBody Map<String, Object> params){
		
		Map<String, Object> result = officialInfoService.findList(params);
		return DataResponse.isOk(result.get("list"),Integer.valueOf(result.get("count").toString()));
	}
	
	
	
	@GetMapping("findDetailById")
	public DataResponse findDetailById(String id){
		
		Map<String, Object> result = officialInfoService.findDetailById(id);
		return DataResponse.isOk(result);
	}
	
	
	@PostMapping("updateById")
	public DataResponse updateById(@RequestBody Map<String, Object> params){
		
		officialInfoService.updateById(params);
		return DataResponse.isOk();
	}
	
	@GetMapping("deleteById")
	public DataResponse deleteById(String id){
		
		officialInfoService.deleteById(id);
		return DataResponse.isOk();
	}
	
	@GetMapping("findListUser")
	public DataResponse findListUser(){
		
		List<Map<String, Object>> result = officialInfoService.findListUser();
		return DataResponse.isOk(result);
	}
	
	
}
